import Vue from 'vue'
import store from '../store'
import http from './interceptor.js'

Vue.prototype.$get = async (url, data) => {
	const resData = [null, null];
	try{
		resData[0] = await http.get(url, {params: data})
	}catch(e){
		//TODO handle the exception
		resData[1] = e
	}
	return resData
},
Vue.prototype.$post = async (url, data) => {
	const resData = [null, null];
	try{
		resData[0] = await http.post(url, data)
	}catch(e){
		//TODO handle the exception
		resData[1] = e
	}
	return resData
},
Vue.prototype.$put = async (url, data) => {
	const resData = [null, null];
	try{
		resData[0] = await http.put(url, data)
	}catch(e){
		//TODO handle the exception
		resData[1] = e
	}
	return resData
}